From d28132e9b9e137e18a8fb8a928c7e1acb0122bd4 Mon Sep 17 00:00:00 2001 From: "awilliam@xenbuild.aw" Date: Wed, 22 Nov 2006 10:10:38 -0700 Subject: [PATCH] [IA64] fix paravirtualization of clone2() system call. If audit is enabled or the child process is ptraced, non-paravirtualized code path is executed. Thus paravirtualized ifs is left unmodifed so that the child process crashes after clone2(). paravirtualize ia64_ret_from_clone() to fix it. Signed-off-by: Isaku Yamahata --- linux-2.6-xen-sparse/arch/ia64/kernel/entry.S | 4 +- linux-2.6-xen-sparse/arch/ia64/xen/xenentry.S | 41 +++++++++++++++++++ .../include/asm-ia64/privop.h | 1 + .../include/asm-ia64/xen/privop.h | 1 + 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/linux-2.6-xen-sparse/arch/ia64/kernel/entry.S b/linux-2.6-xen-sparse/arch/ia64/kernel/entry.S index 67738bb21d..67f37b2c53 100644 --- a/linux-2.6-xen-sparse/arch/ia64/kernel/entry.S +++ b/linux-2.6-xen-sparse/arch/ia64/kernel/entry.S @@ -602,7 +602,7 @@ GLOBAL_ENTRY(ia64_strace_leave_kernel) .ret4: br.cond.sptk ia64_leave_kernel END(ia64_strace_leave_kernel) -GLOBAL_ENTRY(ia64_ret_from_clone) +GLOBAL_ENTRY(__ia64_ret_from_clone) PT_REGS_UNWIND_INFO(0) { /* * Some versions of gas generate bad unwind info if the first instruction of a @@ -628,7 +628,7 @@ GLOBAL_ENTRY(ia64_ret_from_clone) cmp.ne p6,p0=r2,r0 (p6) br.cond.spnt .strace_check_retval ;; // added stop bits to prevent r8 dependency -END(ia64_ret_from_clone) +END(__ia64_ret_from_clone) // fall through GLOBAL_ENTRY(ia64_ret_from_syscall) PT_REGS_UNWIND_INFO(0) diff --git a/linux-2.6-xen-sparse/arch/ia64/xen/xenentry.S b/linux-2.6-xen-sparse/arch/ia64/xen/xenentry.S index bd66913f4f..aad0aac631 100644 --- a/linux-2.6-xen-sparse/arch/ia64/xen/xenentry.S +++ b/linux-2.6-xen-sparse/arch/ia64/xen/xenentry.S @@ -237,6 +237,47 @@ END(xen_trace_syscall) END(ia64_trace_syscall) #endif +#ifdef CONFIG_XEN +GLOBAL_ENTRY(xen_ret_from_clone) + PT_REGS_UNWIND_INFO(0) + movl r16=running_on_xen;; + ld4 r16=[r16];; + cmp.eq p7,p0=r16,r0 +(p7) br.cond.sptk.many __ia64_ret_from_clone;; +#else +GLOBAL_ENTRY(ia64_ret_from_clone) + PT_REGS_UNWIND_INFO(0) +#endif +{ /* + * Some versions of gas generate bad unwind info if the first instruction of a + * procedure doesn't go into the first slot of a bundle. This is a workaround. + */ + nop.m 0 + nop.i 0 + /* + * We need to call schedule_tail() to complete the scheduling process. + * Called by ia64_switch_to() after do_fork()->copy_thread(). r8 contains the + * address of the previously executing task. + */ + br.call.sptk.many rp=ia64_invoke_schedule_tail +} +.ret8: + adds r2=TI_FLAGS+IA64_TASK_SIZE,r13 + ;; + ld4 r2=[r2] + ;; + mov r8=0 + and r2=_TIF_SYSCALL_TRACEAUDIT,r2 + ;; + cmp.ne p6,p0=r2,r0 +(p6) br.cond.spnt .strace_check_retval + ;; // added stop bits to prevent r8 dependency +#ifdef CONFIG_XEN + br.cond.sptk ia64_ret_from_syscall +END(xen_ret_from_clone) +#else +END(ia64_ret_from_clone) +#endif /* * ia64_leave_syscall(): Same as ia64_leave_kernel, except that it doesn't * need to switch to bank 0 and doesn't restore the scratch registers. diff --git a/linux-2.6-xen-sparse/include/asm-ia64/privop.h b/linux-2.6-xen-sparse/include/asm-ia64/privop.h index 28c1e886c0..05935407ee 100644 --- a/linux-2.6-xen-sparse/include/asm-ia64/privop.h +++ b/linux-2.6-xen-sparse/include/asm-ia64/privop.h @@ -49,6 +49,7 @@ #define ia64_leave_kernel __ia64_leave_kernel #define ia64_leave_syscall __ia64_leave_syscall #define ia64_trace_syscall __ia64_trace_syscall +#define ia64_ret_from_clone __ia64_ret_from_clone #define ia64_switch_to __ia64_switch_to #define ia64_pal_call_static __ia64_pal_call_static diff --git a/linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h b/linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h index 6f3c20a8ed..a2615ca7e7 100644 --- a/linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h +++ b/linux-2.6-xen-sparse/include/asm-ia64/xen/privop.h @@ -295,6 +295,7 @@ extern void xen_ptcga(unsigned long addr, unsigned long size); #define ia64_leave_kernel xen_leave_kernel #define ia64_leave_syscall xen_leave_syscall #define ia64_trace_syscall xen_trace_syscall +#define ia64_ret_from_clone xen_ret_from_clone #define ia64_switch_to xen_switch_to #define ia64_pal_call_static xen_pal_call_static -- 2.30.2